#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'

template<typename T=int>
inline T read() {
    T x;
    cin >> x;
    return x;
}

struct Item {
    int begin, end;
    bool book;

    bool operator<(const Item &that) {
        return this->begin < that.begin;

    }

    friend bool operator<(const Item &a, const Item &b) {
        return a.end < b.end;
    }
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<Item> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].begin >> v[i].end;
        v[i].book = false;
    }
    sort(v.begin(), v.end());
    int tot = 0, book = 0;
    while (book < n) {
        ++tot;

        int end = 0;
        for (int i = 0; i < n; i++) {
            if (v[i].book == false && v[i].begin >= end) {
                end = v[i].end;
                v[i].book = true;
                ++book;

            }
        }

    }
    cout << tot;
    return 0;
}
